﻿using Journal.Common.Objects;
using Journal.Common.WebApplication;
using Journal.Domain.IDomainServices;
using Journal.Domain.Models;
using Journal.Front.Presentation.Models;
using Journal.Front.Presentation.Models.StudyRoomModels;
using Journal.Front.Presentation.Models.UserModels;
using Journal.Front.Presentation.PresentationServicesInterfaces;

namespace Journal.Front.Presentation.PresentationServices
{
    public class StudyRoomPresentationService : IStudyRoomPresentationService
    {
        private readonly IUserDomainService userDomainService;

        public StudyRoomPresentationService(IUserDomainService userDomainService)
        {
            this.userDomainService = userDomainService;
        }

        public StudyRoomModel GetStudyRoomModel()
        {
            SystemUser loggedUser = BaseApplication.GetLoggedUser();
            if (loggedUser != null)
            {
                User domainUser = userDomainService.Get(loggedUser.UserId);
                UserModel user = new UserModel(domainUser);
                return new StudyRoomModel(user);
            }

            return null;
        }
    }
}